﻿// ResPkgInsert.cpp: 实现文件
//

#include "pch.h"
#include "ResPkg.h"
#include "ResPkgInsert.h"
#include "afxdialogex.h"


// CResPkgInsert 对话框

IMPLEMENT_DYNAMIC(CResPkgInsert, CDialogEx)

CResPkgInsert::CResPkgInsert(CWnd* pParent /*=nullptr*/)
	: CDialogEx(IDD_INSERT, pParent)
{

}

CResPkgInsert::~CResPkgInsert()
{
}

void CResPkgInsert::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_INSERT_LEVEL, m_comboLevel);
	DDX_Control(pDX, IDC_MFCEDITBROWSE1, m_ebFile);
	DDX_Control(pDX, IDC_INSERT_NAME, m_editSubName);
}


BEGIN_MESSAGE_MAP(CResPkgInsert, CDialogEx)
	ON_BN_CLICKED(IDOK, &CResPkgInsert::OnBnClickedOk)
END_MESSAGE_MAP()


// CResPkgInsert 消息处理程序


BOOL CResPkgInsert::OnInitDialog()
{
	CDialogEx::OnInitDialog();

	m_comboLevel.SetCurSel(5);

	return TRUE;  // return TRUE unless you set the focus to a control
				  // 异常: OCX 属性页应返回 FALSE
}


void CResPkgInsert::OnBnClickedOk()
{
	m_ebFile.GetWindowText(m_strFilePath);
	m_editSubName.GetWindowText(m_strSubName);
	if (m_strFilePath != _T("") && m_strSubName != _T(""))
	{
		if (m_editSubName.GetWindowTextLength() * sizeof(TCHAR) > MAX_SUBNAME_LEN)
		{
			CString strErr;
			strErr.LoadString(IDS_SUBNAME_LIMIT);
			MessageBox(strErr);
		}
		else
		{
			m_nLevel = m_comboLevel.GetCurSel() + 1;
			CDialogEx::OnOK();
		}
	}
	else
	{
		CString strWarn;
		strWarn.LoadString(IDS_EMPTY_NAME);
		MessageBox(strWarn);
	}
}
